#!/dis/sh.dis
# emu sh initialisation here
load std

# create mounting points as hg cannot take empty dirs
mkdir /n /mnt /tmp /me >[2] /dev/null
mkdir /mnt/acme /mnt/arch /mnt/factotum /mnt/registry /mnt/schedule /mnt/wiki >[2] /dev/null

user="{cat /dev/user}
home=/usr/^$"user
mount -ac {mntgen} /n
ftrans=()

if {~ $emuhost MacOSX Linux}{
	trfs '#U*' /n/local >[2] /dev/null
	ftrans = $frans '#U*' /n/local
	ghome=/n/local^`{echo 'echo $HOME' | os sh}
}{~ $emuhost Nt}{
	for i in c d {  # add more drive letters to suit
		trfs '#U' ^ $i ^ ':/' /n/$i >[2] /dev/null
		ftrans = $ftrans '#U' ^ $i ^ ':/'  /n/$i
	}
	ghome=/n/c
}{ else
	ghome=$home
}
lhome=$ghome^/acme-home
mount -a {mntgen} /usr

# setup for 1st time user
if {! ftest -d $lhome}{
	cp -r /usr/inferno $lhome
	bind -c /usr/inferno $home
	mkdir -p $home/tmp
}

bind -c $lhome $home
bind -bc $home/tmp /tmp
bind -c $ghome /me

cd $home
run $home/lib/profile
